<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <button id='connect'>连接</button>
    <button id='send'>发送</button>
    <script>
        const connect = document.querySelector('#connect')
        const send = document.querySelector('#send')
        let ws = null
        connect.onclick=function(){
            // ws连接
            ws = new WebSocket('ws:127.0.0.1:9998')
            ws.onopen =()=>{
                console.log('连接成功');
            }
            ws.onclose=()=>{
                console.log('连接失败');
            }
            ws.onmessage=(msg)=>{
                console.log('服务的发送:',msg.data);
                console.log(msg);
            }
        }
        send.onclick=function(){
            ws.send(JSON.stringify({
                action:'fullScreen',
                socketType:'trenData',
                chartName:'trend',
                value:true
            }))
        }
    </script>
</body>
</html>